/****

    activequant - activestocks.eu

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

	
	contact  : contact@activestocks.eu
    homepage : http://www.activestocks.eu

****/
package org.activequant.util.spring;

import java.beans.PropertyEditorSupport;

import org.activequant.core.types.TimeFrame;

/**
 * maps a timeframe.<br>
 * TimeFramePropertyEditor extends PropertyEditorSupport
 * <br>
 * <b>History:</b><br>
 *  - [07.10.2007] Created (Ulrich Staudinger)<br>
 *
 *  @author Ulrich Staudinger
 */
public class TimeFramePropertyEditor extends PropertyEditorSupport {
	/**
	 * <strong>1.</strong> Parses/creates a timeFrame(TimeFrame) from the given text(String).<br/>
	 * The given text(String) has to be in the form "${length}${acronym}", where length is a number and acronym is 
	 * <strong>"s"</strong>, <strong>"m"</strong>, <strong>"h"</strong>, <strong>"d"</strong>, <strong>"w"</strong>, <strong>"M"</strong> or <strong>"Y"</strong><br/>
	 * The TimeFrame will have the parsed length(int) and unit(Unit) enum matching that acronym.<br/>
	 * <strong>2.</strong> Sets the inherited value(Object) of this TimeFramePropertyEditor with that timeFrame(TimeFrame)
	 */
    public void setAsText(String text) {
        setValue(TimeFrame.parse(text));
    }
	
}